package com.eduhzy.ttw.teacher.di.module;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.eduhzy.ttw.commonsdk.entity.ChooseSubjectData;
import com.eduhzy.ttw.commonsdk.holder.AutoBaseViewHolder;
import com.eduhzy.ttw.teacher.R;
import com.eduhzy.ttw.teacher.mvp.contract.ChooseSubjectContract;
import com.eduhzy.ttw.teacher.mvp.model.ChooseSubjectModel;
import com.jess.arms.di.scope.ActivityScope;

import java.util.ArrayList;
import java.util.List;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;


@Module
public abstract class ChooseSubjectModule {

    @Binds
    abstract ChooseSubjectContract.Model bindChooseSubjectModel(ChooseSubjectModel model);
    @ActivityScope
    @Provides
    static List<ChooseSubjectData> provideList() {
        return new ArrayList<>();
    }

    @ActivityScope
    @Provides
    static BaseQuickAdapter<ChooseSubjectData, AutoBaseViewHolder> provideActivityAdapter(List<ChooseSubjectData> list) {
        return new BaseQuickAdapter<ChooseSubjectData, AutoBaseViewHolder>(R.layout.rv_item_choose_class, list) {
            @Override
            protected void convert(AutoBaseViewHolder helper, ChooseSubjectData item) {
                helper.setText(R.id.class_name, item.getName());
                helper.getView(R.id.class_selected_btn).setSelected(item.isSelect());
            }
        };
    }

    @ActivityScope
    @Provides
    static RecyclerView.LayoutManager provideLayoutManger(ChooseSubjectContract.View view) {
        return new LinearLayoutManager(view.getActivity());
    }

}